package resources.dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


import resources.util.JDCConnectionDriver;

public abstract class DatabaseDAO {
	public static Connection conn;
	public static PreparedStatement ps;
	public static CallableStatement cs;
	public static ResultSet rs;
	
	public static Connection getDBPoolConnection(){		
		try{
			new JDCConnectionDriver("com.mysql.jdbc.Driver", 
					"jdbc:mysql://localhost:3306/hvhsolution?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true","root", "123");
			return conn = DriverManager.getConnection("jdbc:jdc:jdcpool");
		}catch (Exception e) {
			e.printStackTrace(System.out);
			return null;
		}
	}
	
	public static void closeConnection(){
		try {
			if(conn!=null)conn.close();
			if(ps!=null)ps.close();
			if(cs!=null)cs.close();
			if(rs!=null)rs.close();			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}	
}
